home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility2 / wine02bx.zip / INFO / EMACS.12 < prev    next >
Text File  |  1993-03-28  |  49KB  |  1,177 lines

  1. Info file ../info/emacs, produced by Makeinfo, -*- Text -*- from input
  2. file lemacs.tex.
  3.  
  4.    This file documents the GNU Emacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992 Lucid, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of
  10. this manual provided the copyright notice and this permission notice
  11. are preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  16. General Public License" are included exactly as in the original, and
  17. provided that the entire resulting derived work is distributed under
  18. the terms of a permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "The GNU Manifesto",
  23. "Distribution" and "GNU General Public License" may be included in a
  24. translation approved by the author instead of in the original English.
  25.  
  26. 
  27. File: emacs,  Node: Sorting,  Next: Shell,  Prev: Narrowing,  Up: Top
  28.  
  29. Sorting Text
  30. ============
  31.  
  32.    Emacs provides several commands for sorting text in a buffer.  All
  33. operate on the contents of the region (the text between point and the
  34. mark).  They divide the text of the region into many "sort records",
  35. identify a "sort key" for each record, and then reorder the records
  36. using the order determined by the sort keys.  The records are ordered
  37. so that their keys are in alphabetical order, or, for numeric sorting,
  38. in numeric order.  In alphabetic sorting, all upper case letters `A'
  39. through `Z' come before lower case `a', in accord with the ASCII
  40. character sequence.
  41.  
  42.    The sort commands differ in how they divide the text into sort
  43. records and in which part of each record they use as the sort key. 
  44. Most of the commands make each line a separate sort record, but some
  45. commands use paragraphs or pages as sort records.  Most of the sort
  46. commands use each entire sort record as its own sort key, but some use
  47. only a portion of the record as the sort key.
  48.  
  49. `M-x sort-lines'
  50.      Divide the region into lines, and sort by comparing the entire
  51.      text of a line.  A prefix argument means sort in descending order.
  52.  
  53. `M-x sort-paragraphs'
  54.      Divide the region into paragraphs and sort by comparing the entire
  55.      text of a paragraph (except for leading blank lines).  A prefix
  56.      argument means sort in descending order.
  57.  
  58. `M-x sort-pages'
  59.      Divide the region into pages, and sort by comparing the entire
  60.      text of a page (except for leading blank lines).  A prefix
  61.      argument means sort in descending order.
  62.  
  63. `M-x sort-fields'
  64.      Divide the region into lines, and sort by comparing the contents
  65.      of one field in each line.  Fields are defined as separated by
  66.      whitespace, so the first run of consecutive non-whitespace
  67.      characters in a line constitutes field 1, the second such run
  68.      constitutes field 2, etc.
  69.  
  70.      You specify which field to sort by with a numeric argument: 1 to
  71.      sort by field 1, etc.  A negative argument means sort in
  72.      descending order.  Thus, minus 2 means sort by field 2 in
  73.      reverse-alphabetical order.
  74.  
  75. `M-x sort-numeric-fields'
  76.      Like `M-x sort-fields' except the specified field is converted to
  77.      a number for each line, and the numbers are compared.  `10' comes
  78.      before `2' when considered as text, but after it when considered
  79.      as a number.
  80.  
  81. `M-x sort-columns'
  82.      Like `M-x sort-fields' except that the text within each line used
  83.      for comparison comes from a fixed range of columns.  An
  84.      explanation is given below.
  85.  
  86.    For example, if the buffer contains
  87.  
  88.      On systems where clash detection (locking of files being edited) is
  89.      implemented, Emacs also checks the first time you modify a buffer
  90.      whether the file has changed on disk since it was last visited or
  91.      saved.  If it has, you are asked to confirm that you want to change
  92.      the buffer.
  93.  
  94. then if you apply `M-x sort-lines' to the entire buffer you get
  95.  
  96.      On systems where clash detection (locking of files being edited) is
  97.      implemented, Emacs also checks the first time you modify a buffer
  98.      saved.  If it has, you are asked to confirm that you want to change
  99.      the buffer.
  100.      whether the file has changed on disk since it was last visited or
  101.  
  102. where the upper case `O' comes before all lower case letters.  If you
  103. apply instead `C-u 2 M-x sort-fields' you get
  104.  
  105.      implemented, Emacs also checks the first time you modify a buffer
  106.      saved.  If it has, you are asked to confirm that you want to change
  107.      the buffer.
  108.      On systems where clash detection (locking of files being edited) is
  109.      whether the file has changed on disk since it was last visited or
  110.  
  111. where the sort keys were `Emacs', `If', `buffer', `systems' and `the'.
  112.  
  113.    `M-x sort-columns' requires more explanation.  You specify the
  114. columns by putting point at one of the columns and the mark at the
  115. other column.  Because this means you cannot put point or the mark at
  116. the beginning of the first line to sort, this command uses an unusual
  117. definition of `region': all of the line point is in is considered part
  118. of the region, and so is all of the line the mark is in.
  119.  
  120.    For example, to sort a table by information found in columns 10 to
  121. 15, you could put the mark on column 10 in the first line of the
  122. table, and point on column 15 in the last line of the table, and then
  123. use this command.  Or you could put the mark on column 15 in the first
  124. line and point on column 10 in the last line.
  125.  
  126.    This can be thought of as sorting the rectangle specified by point
  127. and the mark, except that the text on each line to the left or right
  128. of the rectangle moves along with the text inside the rectangle. 
  129. *Note Rectangles::.
  130.  
  131. 
  132. File: emacs,  Node: Shell,  Next: Hardcopy,  Prev: Sorting,  Up: Top
  133.  
  134. Running Shell Commands from Emacs
  135. =================================
  136.  
  137.    Emacs has commands for passing single command lines to inferior
  138. shell processes; it can also run a shell interactively with input and
  139. output to an Emacs buffer `*shell*'.
  140.  
  141. `M-!'
  142.      Run a specified shell command line and display the output
  143.      (`shell-command').
  144.  
  145. `M-|'
  146.      Run a specified shell command line with region contents as input;
  147.      optionally replace the region with the output
  148.      (`shell-command-on-region').
  149.  
  150. `M-x shell'
  151.      Run a subshell with input and output through an Emacs buffer. 
  152.      You can then give commands interactively.
  153.  
  154. * Menu:
  155.  
  156. * Single Shell::         How to run one shell command and return.
  157. * Interactive Shell::    Permanent shell taking input via Emacs.
  158. * Shell Mode::           Special Emacs commands used with permanent shell.
  159.  
  160. 
  161. File: emacs,  Node: Single Shell,  Next: Interactive Shell,  Prev: Shell,  Up: Shell
  162.  
  163. Single Shell Commands
  164. ---------------------
  165.  
  166.    `M-!' (`shell-command') reads a line of text using the minibuffer
  167. and creates an inferior shell to execute the line as a command. 
  168. Standard input from the command comes from the null device.  If the
  169. shell command produces any output, the output goes to an Emacs buffer
  170. named `*Shell Command Output*', which is displayed in another window
  171. but not selected.  A numeric argument, as in `M-1 M-!', directs this
  172. command to insert any output into the current buffer.  In that case,
  173. point is left before the output and the mark is set after the output.
  174.  
  175.    `M-|' (`shell-command-on-region') is like `M-!' but passes the
  176. contents of the region as input to the shell command, instead of no
  177. input.  If a numeric argument is used to direct  output to the current
  178. buffer, then the old region is deleted first and the output replaces
  179. it as the contents of the region.
  180.  
  181.    Both `M-!' and `M-|' use `shell-file-name' to specify the shell to
  182. use.  This variable is initialized based on your `SHELL' environment
  183. variable when you start Emacs.  If the file name does not specify a
  184. directory, the directories in the list `exec-path' are searched; this
  185. list is initialized based on the `PATH' environment variable when you
  186. start Emacs.  You can override either or both of these default
  187. initializations in your `.emacs' file .
  188.  
  189.    When you use `M-!' and `M-|', Emacs has to wait until the shell
  190. command completes.  You can quit with `C-g'; that terminates the shell
  191. command.
  192.  
  193. 
  194. File: emacs,  Node: Interactive Shell,  Next: Shell Mode,  Prev: Single Shell,  Up: Shell
  195.  
  196. Interactive Inferior Shell
  197. --------------------------
  198.  
  199.    To run a subshell interactively with its typescript in an Emacs
  200. buffer, use `M-x shell'.  This creates (or reuses) a buffer named
  201. `*shell*' and runs a subshell with input coming from and output going
  202. to that buffer.  That is to say, any "terminal output" from the
  203. subshell will go into the buffer, advancing point, and any "terminal
  204. input" for the subshell comes from text in the buffer.  To give input
  205. to the subshell, go to the end of the buffer and type the input,
  206. terminated by RET.
  207.  
  208.    Emacs does not wait for the subshell to do anything.  You can switch
  209. windows or buffers and edit them while the shell is waiting, or while
  210. it is running a command.  Output from the subshell waits until Emacs
  211. has time to process it; this happens whenever Emacs is waiting for
  212. keyboard input or for time to elapse.
  213.  
  214.    To get multiple subshells, change the name of buffer `*shell*' to
  215. something different by using `M-x rename-buffer'.  The next use of
  216. `M-x shell' creates a new buffer `*shell*' with its own subshell.  By
  217. renaming this buffer as well you can create a third one, and so on. 
  218. All the subshells run independently and in parallel.
  219.  
  220.    The file name used to load the subshell is the value of the variable
  221. `explicit-shell-file-name', if that is non-`nil'.  Otherwise, the
  222. environment variable `ESHELL' is used, or the environment variable
  223. `SHELL' if there is no `ESHELL'.  If the file name specified is
  224. relative, the directories in the list `exec-path' are searched (*note
  225. Single Shell Commands: Single Shell.).
  226.  
  227.    As soon as the subshell is started, it is sent as input the
  228. contents of the file `~/.emacs_SHELLNAME', if that file exists, where
  229. SHELLNAME is the name of the file that the shell was loaded from.  For
  230. example, if you use `csh', the file sent to it is `~/.emacs_csh'.
  231.  
  232.    `cd', `pushd' and `popd' commands given to the inferior shell are
  233. watched by Emacs so it can keep the `*shell*' buffer's default
  234. directory the same as the shell's working directory.  These commands
  235. are recognized syntactically by examining lines of input that are
  236. sent.  If you use aliases for these commands, you can tell Emacs to
  237. recognize them also.  For example, if the value of the variable
  238. `shell-pushd-regexp' matches the beginning of a shell command line,
  239. that line is regarded as a `pushd' command.  Change this variable when
  240. you add aliases for `pushd'.  Likewise, `shell-popd-regexp' and
  241. `shell-cd-regexp' are used to recognize commands with the meaning of
  242. `popd' and `cd'.
  243.  
  244.    `M-x shell-resync-dirs' queries the shell and resynchronizes Emacs'
  245. idea of what the current directory stack is.  `M-x
  246. shell-dirtrack-toggle' turns directory tracking on and off.
  247.  
  248.    Emacs keeps a history of the most recent commands you have typed in
  249. the `*shell*' buffer.  If you are at the beginning of a shell command
  250. line and type M-p, the previous shell input is inserted into the
  251. buffer before point.  Immediately typing M-p again deletes that input
  252. and inserts the one before it.  By repeating M-p you can move backward
  253. through your commands until you find one you want to repeat.  You may
  254. then edit the command before typing RET if you wish. M-n moves forward
  255. through the command history, in case you moved backward past the one
  256. you wanted while using M-p.  If you type the first few characters of a
  257. previous command and then type M-p, the most recent shell input
  258. starting with those characters is inserted.  This can be very
  259. convenient when you are repeating a sequence of shell commands.  The
  260. variable `input-ring-size' controls how many commands are saved in
  261. your input history.  The default is 30.
  262.  
  263. 
  264. File: emacs,  Node: Shell Mode,  Prev: Interactive Shell,  Up: Shell
  265.  
  266. Shell Mode
  267. ----------
  268.  
  269.    The shell buffer uses Shell mode, which defines several special keys
  270. attached to the `C-c' prefix.  They are chosen to resemble the usual
  271. editing and job control characters present in shells that are not under
  272. Emacs, except that you must type `C-c' first.  Here is a list of the
  273. special key bindings of Shell mode:
  274.  
  275. `RET'
  276.      At end of buffer send line as input; otherwise, copy current line
  277.      to end of buffer and send it (`send-shell-input').  When a line
  278.      is copied, any text at the beginning of the line that matches the
  279.      variable `shell-prompt-pattern' is left out; this variable's
  280.      value should be a regexp string that matches the prompts that you
  281.      use in your subshell.
  282.  
  283. `C-c C-d'
  284.      Send end-of-file as input, probably causing the shell or its
  285.      current subjob to finish (`shell-send-eof').
  286.  
  287. `C-d'
  288.      If point is not at the end of the buffer, delete the next
  289.      character just like most other modes.  If point is at the end of
  290.      the buffer, send end-of-file as input (instead of generating an
  291.      error as in other modes).
  292.  
  293. `C-c C-u'
  294.      Kill all text that has yet to be sent as input
  295.      (`kill-shell-input').
  296.  
  297. `C-c C-w'
  298.      Kill a word before point (`backward-kill-word').
  299.  
  300. `C-c C-c'
  301.      Interrupt the shell or its current subjob if any
  302.      (`interrupt-shell-subjob').
  303.  
  304. `C-c C-z'
  305.      Stop the shell or its current subjob if any (`stop-shell-subjob').
  306.  
  307. `C-c C-\'
  308.      Send quit signal to the shell or its current subjob if any
  309.      (`quit-shell-subjob').
  310.  
  311. `C-c C-o'
  312.      Delete last batch of output from shell (`kill-output-from-shell').
  313.  
  314. `C-c C-r'
  315.      Scroll top of last batch of output to top of window
  316.      (`show-output-from-shell').
  317.  
  318. `C-c C-y'
  319.      Copy the previous bunch of shell input, and insert it into the
  320.      buffer before point (`copy-last-shell-input').  No final newline
  321.      is inserted, and the input copied is not resubmitted until you
  322.      type RET.
  323.  
  324. `M-p'
  325.      Move backward through the input history.  Search for a matching
  326.      command if you have typed the beginning of a command.
  327.  
  328. `M-n'
  329.      Move forward through the input history.  Useful when you are
  330.      using M-p quickly and go past the desired command.
  331.  
  332. `TAB'
  333.      Complete the file name preceding point.
  334.  
  335. 
  336. File: emacs,  Node: Hardcopy,  Next: Dissociated Press,  Prev: Shell,  Up: Top
  337.  
  338. Hardcopy Output
  339. ===============
  340.  
  341.    The Emacs commands for making hardcopy derive their names from the
  342. Unix commands `print' and `lpr'.
  343.  
  344. `M-x print-buffer'
  345.      Print hardcopy of current buffer using Unix command `print' 
  346.      (`lpr -p').  This command adds page headings containing the file
  347.      name and page number.
  348.  
  349. `M-x lpr-buffer'
  350.      Print hardcopy of current buffer using Unix command `lpr'.  This
  351.      command does not add page headings.
  352.  
  353. `M-x print-region'
  354.      Like `print-buffer' but prints only the current region.
  355.  
  356. `M-x lpr-region'
  357.      Like `lpr-buffer' but prints only the current region.
  358.  
  359.    All the hardcopy commands pass extra switches to the `lpr' program
  360. based on the value of the variable `lpr-switches'.  Its value should
  361. be a list of strings, each string a switch starting with `-'.  For
  362. example, the value could be `("-Pfoo")' to print on printer `foo'.
  363.  
  364. 
  365. File: emacs,  Node: Dissociated Press,  Next: CONX,  Prev: Hardcopy,  Up: Top
  366.  
  367. Dissociated Press
  368. =================
  369.  
  370.    `M-x dissociated-press' is a command for scrambling a file of text
  371. either word by word or character by character.  Starting from a buffer
  372. of straight English, it produces extremely amusing output.  The input
  373. comes from the current Emacs buffer.  Dissociated Press writes its
  374. output in a buffer named `*Dissociation*', and redisplays that buffer
  375. after every couple of lines (approximately) to facilitate reading it.
  376.  
  377.    `dissociated-press' asks every so often whether to continue
  378. operating.  Answer `n' to stop it.  You can also stop at any time by
  379. typing `C-g'.  The dissociation output remains in the `*Dissociation*'
  380. buffer for you to copy elsewhere if you wish.
  381.  
  382.    Dissociated Press operates by jumping at random from one point in
  383. the buffer to another.  In order to produce plausible output rather
  384. than gibberish, it insists on a certain amount of overlap between the
  385. end of one run of consecutive words or characters and the start of the
  386. next.  That is, if it has just printed out `president' and then
  387. decides to jump to a different point in the file, it might spot the
  388. `ent' in `pentagon' and continue from there, producing
  389. `presidentagon'.  Long sample texts produce the best results.
  390.  
  391.    A positive argument to `M-x dissociated-press' tells it to operate
  392. character by character, and specifies the number of overlap
  393. characters.  A negative argument tells it to operate word by word and
  394. specifies the number of overlap words.  In this mode, whole words are
  395. treated as the elements to be permuted, rather than characters.  No
  396. argument is equivalent to an argument of two.  For your
  397. againformation, the output goes only into the buffer `*Dissociation*'.
  398.  The buffer you start with is not changed.
  399.  
  400.    Dissociated Press produces nearly the same results as a Markov chain
  401. based on a frequency table constructed from the sample text.  It is,
  402. however, an independent, ignoriginal invention.  Dissociated Press
  403. techniquitously copies several consecutive characters from the sample
  404. between random choices, whereas a Markov chain would choose randomly
  405. for each word or character.  This makes for more plausible sounding
  406. results, and runs faster.
  407.  
  408.    It is a mustatement that too much use of Dissociated Press can be a
  409. developediment to your real work.  Sometimes to the point of outragedy. 
  410. And keep dissociwords out of your documentation, if you want it to be
  411. well userenced and properbose.  Have fun.  Your buggestions are
  412. welcome.
  413.  
  414. 
  415. File: emacs,  Node: CONX,  Next: Amusements,  Prev: Dissociated Press,  Up: Top
  416.  
  417. CONX
  418. ====
  419.  
  420.    Besides producing a file of scrambled text with Dissociated Press,
  421. you can generate random sentences by using CONX.
  422.  
  423. `M-x conx'
  424.      Generate random sentences in the *conx* buffer.
  425.  
  426. `M-x conx-buffer'
  427.      Absorb the text in the current buffer into the `conx' database.
  428.  
  429. `M-x conx-init'
  430.      Forget the current word-frequency tree.
  431.  
  432. `M-x conx-load'
  433.      Load a `conx' database that has been previously saved with `M-x
  434.      conx-save'.
  435.  
  436. `M-x conx-region'
  437.      Absorb the text in the current buffer into the conx database.
  438.  
  439. `M-x conx-save'
  440.      Save the current conx database to a file for future retrieval.
  441.  
  442.    Copy text from a buffer using `M-x conx-buffer' or `M-x conx-region'
  443. and then type `M-x conx'.  Output is continuously generated until you
  444. type ^G. You can save the `conx' database to a file with `M-x
  445. conx-save', which you can retrieve with `M-x conx-load'.  To clear the
  446. database, use `M-x conx-init'.
  447.  
  448. 
  449. File: emacs,  Node: Amusements,  Next: Emulation,  Prev: CONX,  Up: Top
  450.  
  451. Other Amusements
  452. ================
  453.  
  454.    If you are a little bit bored, you can try `M-x hanoi'.  If you are
  455. considerably bored, give it a numeric argument.  If you are very very
  456. bored, try an argument of 9.  Sit back and watch.
  457.  
  458.    When you are frustrated, try the famous Eliza program.  Just do
  459. `M-x doctor'.  End each input by typing `RET' twice.
  460.  
  461.    When you are feeling strange, type `M-x yow'.
  462.  
  463. 
  464. File: emacs,  Node: Emulation,  Next: Customization,  Prev: Amusements,  Up: Top
  465.  
  466. Emulation
  467. =========
  468.  
  469.    GNU Emacs can be programmed to emulate (more or less) most other
  470. editors.  Standard facilities can emulate these:
  471.  
  472. EDT (DEC VMS editor)
  473.      Turn on EDT emulation with `M-x edt-emulation-on'.  `M-x 
  474.      edt-emulation-off' restores normal Emacs command bindings.
  475.  
  476.      Most of the EDT emulation commands are keypad keys, and most
  477.      standard Emacs key bindings are still available.  The EDT
  478.      emulation rebindings are done in the global keymap, so there is
  479.      no problem switching buffers or major modes while in EDT
  480.      emulation.
  481.  
  482. Gosling Emacs
  483.      Turn on emulation of Gosling Emacs (aka Unipress Emacs) with `M-x
  484.      set-gosmacs-bindings'.  This redefines many keys, mostly on the
  485.      `C-x' and `ESC' prefixes, to work as they do in Gosmacs.  `M-x
  486.      set-gnu-bindings' returns to normal GNU Emacs by rebinding the
  487.      same keys to the definitions they had at the time `M-x
  488.      set-gosmacs-bindings' was done.
  489.  
  490.      It is also possible to run Mocklisp code written for Gosling
  491.      Emacs.  *Note Mocklisp::.
  492.  
  493. evi (vi emulation in Lucid GNU Emacs)
  494.      In Lucid GNU Emacs, evi is the emulation of vi within Emacs.  By
  495.      default, evi-mode is as close as possible to regular vi.  To
  496.      start evi mode from Emacs, type: `Meta-x evi'.
  497.  
  498.      If you want be in evi mode whenever you bring up Emacs, include
  499.      this line in your `.emacs' file:
  500.  
  501.           (setq term-setup-hook 'evi)
  502.  
  503.           *Note evi Mode:: for more information on evi Mode.
  504.  
  505. vi (Berkeley Unix editor)
  506.      Turn on vi emulation with `M-x vi-mode'.  This is a major mode
  507.      that replaces the previously established major mode.  All of the
  508.      vi commands that, in real vi, enter "input" mode are programmed
  509.      in the Emacs emulator to return to the previous major mode.  Thus,
  510.      ordinary Emacs serves as vi's "input" mode.
  511.  
  512.      Because vi emulation works through major modes, it does not work
  513.      to switch buffers during emulation.  Return to normal Emacs first.
  514.  
  515.      If you plan to use vi emulation much, you probably want to bind a
  516.      key to the `vi-mode' command.
  517.  
  518. vi (alternate emulator)
  519.      Another vi emulator said to resemble real vi more thoroughly is
  520.      invoked by `M-x vip-mode'.  "Input" mode in this emulator is
  521.      changed from ordinary Emacs so you can use ESC to go back to
  522.      emulated vi command mode.  To get from emulated vi command mode
  523.      back to ordinary Emacs, type `C-z'.
  524.  
  525.      This emulation does not work through major modes, and it is
  526.      possible to switch buffers in various ways within the emulator. 
  527.      It is not so necessary to assign a key to the command `vip-mode'
  528.      as it is with `vi-mode' because terminating insert mode does not
  529.      use it.
  530.  
  531.      For full information, see the long comment at the beginning of the
  532.      source file, which is `lisp/vip.el' in the Emacs distribution.
  533.  
  534.    Warning: loading more than one vi emulator at once may cause name
  535. conficts; no one has checked.
  536.  
  537. * Menu:
  538.  
  539. * evi Mode:: Brief discussion of evi, the vi Emulation mode within Lucid
  540.              GNU Emacs
  541.  
  542. 
  543. File: emacs,  Node: evi Mode,  Prev: Emulation,  Up: Emulation
  544.  
  545. Using evi Mode
  546. --------------
  547.  
  548.    In Lucid GNU Emacs, evi provides vi emulation within Emacs.  By
  549. default, evi-mode is as close as possible to regular vi.  To start evi
  550. mode from Emacs, type: `Meta-x evi' If you want be in evi mode
  551. whenever you bring up Emacs, include this line in your `.emacs' file:
  552.  
  553.      (setq term-setup-hook 'evi)
  554.  
  555.    You can find a customization file for evi-mode in `~/.evirc'.  This
  556. file has to contain Lisp code, just like the `.emacs' file, and is
  557. loaded whenever you invoke evi mode.  The file allows you to rebind
  558. keys in evi mode, just as you can in other Emacs modes.
  559.  
  560.    Note that evi also loads a file of vi commands from `.exrc', just
  561. like vi.
  562.  
  563.    By default, all Emacs commands are disabled in evi mode.  This
  564. leaves you with only vi commands.  You may customize evi mode to make
  565. certain keybindings accessible.  For example, to enable all emacs
  566. command sequences that begin with `Control-x' or with `Meta', include
  567. the following lines in your `.evirc' file:
  568.  
  569.      (evi-define-key evi-all-keymaps "\C-x" ctl-x-map)
  570.      (setq evi-meta-prefix-char ?\C-a)
  571.      (evi-define-key evi-all-keymaps "\C-a" esc-map)
  572.  
  573.    When you are in evi mode, typing `Control-z' stops vi emulation,
  574. leaving you in Emacs.  To get back into evi mode, use `Meta-x evi'
  575. again.  To exit Emacs, use `Control-x Control-c'.
  576.  
  577.    The file management commands used by vi have been adapted to Emacs. 
  578. They have slightly different meanings than the vi commands itself:
  579.  
  580. `:e'
  581.      Edit a file in the current window.  With no argument, brings in a
  582.      new copy of the file, if it has been subsequently modified on
  583.      disk.  `:e' overrides any complaints about the current buffer
  584.      being modified and discards all modifications.  With a filename
  585.      argument, it edits that file in the current window, using the
  586.      copy already in the editor if it was previously read in.  There
  587.      is no difference between `:e!  filename' and `:e filename'.  As a
  588.      shorthand for editing the most recently accessed buffer not in
  589.      the window, use `:e#'.
  590.  
  591. `:E'
  592.      Same as `:e', but edits the file in another window, creating that
  593.      window if necessary.  If used with no filename, this command
  594.      splits the current buffer into two windows.
  595.  
  596. `:n'
  597.      Switch to the next file in the buffer list that is not currently
  598.      displayed.  Rotates the current file to the end of the buffer
  599.      list, so the command effectively cycles through all buffers.
  600.  
  601. `:N'
  602.      Same as `:n', but switches to another window or creates another
  603.      window and puts the next file into it.
  604.  
  605.    All `ex' commands that accept filenames as arguments perform file
  606. completion using `Space' or `Tab'.  Completion begins after the space
  607. that separates the command from the filename.
  608.  
  609.    Many of the `ex' commands are not implemented.  The following
  610. commands are implemented:
  611.  
  612.      cd, chdir, copy, delete, edit, file, global, map, move, next print,
  613.      put, quit, read, set, source, substitute, tag, write, wq, yank, !, <, >
  614.  
  615.    The following `ex' options are implemented:
  616.  
  617.      autoindent, ignorecase, magic, notimeout, shiftwidth, showmatch,
  618.      tabstop, wrapscan
  619.  
  620. 
  621. File: emacs,  Node: Customization,  Next: Quitting,  Prev: Emulation,  Up: Top
  622.  
  623. Customization
  624. *************
  625.  
  626.    This chapter talks about various topics relevant to adapting the
  627. behavior of Emacs in minor ways.
  628.  
  629.    All kinds of customization affect only the particular Emacs job
  630. that you do them in.  They are completely lost when you kill the Emacs
  631. job, and have no effect on other Emacs jobs you may run at the same
  632. time or later.  The only way an Emacs job can affect anything outside
  633. of it is by writing a file; in particular, the only way to make a
  634. customization `permanent' is to put something in your `.emacs' file or
  635. other appropriate file to do the customization in each session.  *Note
  636. Init File::.
  637.  
  638. * Menu:
  639.  
  640. * Minor Modes::     Each minor mode is one feature you can turn on
  641.                      independently of any others.
  642. * Variables::       Many Emacs commands examine Emacs variables
  643.                      to decide what to do; by setting variables,
  644.                      you can control their functioning.
  645. * Keyboard Macros:: A keyboard macro records a sequence of keystrokes
  646.                      to be replayed with a single command.
  647. * Key Bindings::    The keymaps say what command each key runs.
  648.                      By changing them, you can "redefine keys".
  649. * Syntax::          The syntax table controls how words and expressions
  650.                      are parsed.
  651. * Init File::       How to write common customizations in the `.emacs'
  652.                      file.
  653. * Audible Bell::    Changing how Emacs sounds the bell.
  654. * Faces::
  655.                     Changing the fonts and colors of a region of text.
  656.  
  657. 
  658. File: emacs,  Node: Minor Modes,  Next: Variables,  Up: Customization
  659.  
  660. Minor Modes
  661. ===========
  662.  
  663.    Minor modes are options which you can use or not.  For example, Auto
  664. Fill mode is a minor mode in which SPC breaks lines between words as
  665. you type.  All the minor modes are independent of each other and of
  666. the selected major mode.  Most minor modes inform you in the mode line
  667. when they are on; for example, `Fill' in the mode line means that Auto
  668. Fill mode is on.
  669.  
  670.    Append `-mode' to the name of a minor mode to get the name of a
  671. command function that turns the mode on or off.  Thus, the command to
  672. enable or disable Auto Fill mode is called `M-x auto-fill-mode'.  These
  673. commands are usually invoked with `M-x', but you can bind keys to them
  674. if you wish.  With no argument, the function turns the mode on if it
  675. was off and off if it was on.  This is known as "toggling".  A positive
  676. argument always turns the mode on, and an explicit zero argument or a
  677. negative argument always turns it off.
  678.  
  679.    Auto Fill mode allows you to enter filled text without breaking
  680. lines explicitly.  Emacs inserts newlines as necessary to prevent
  681. lines from becoming too long.  *Note Filling::.
  682.  
  683.    Overwrite mode causes ordinary printing characters to replace
  684. existing text instead of moving it to the right.  For example, if
  685. point is in front of the `B' in `FOOBAR', and you type a `G' in
  686. Overwrite mode, it changes to `FOOGAR', instead of `FOOGBAR'.
  687.  
  688.    Abbrev mode allows you to define abbreviations that automatically
  689. expand as you type them.  For example, `amd' might expand to `abbrev
  690. mode'.  *Note Abbrevs::, for full information.
  691.  
  692. 
  693. File: emacs,  Node: Variables,  Next: Keyboard Macros,  Prev: Minor Modes,  Up: Customization
  694.  
  695. Variables
  696. =========
  697.  
  698.    A "variable" is a Lisp symbol which has a value.  The symbol's name
  699. is also called the name of the variable.  Variable names can contain
  700. any characters, but conventionally they are chosen to be words
  701. separated by hyphens.  A variable can have a documentation string
  702. which describes what kind of value it should have and how the value
  703. will be used.
  704.  
  705.    Lisp allows any variable to have any kind of value, but most
  706. variables that Emacs uses require a value of a certain type.  Often
  707. the value has to be a string, or has to be a number.  Sometimes we say
  708. that a certain feature is turned on if a variable is "non-`nil',"
  709. meaning that if the variable's value is `nil', the feature is off, but
  710. the feature is on for any other value.  The conventional value to turn
  711. on the feature--since you have to pick one particular value when you
  712. set the variable--is `t'.
  713.  
  714.    Emacs uses many Lisp variables for internal recordkeeping, as any
  715. Lisp program must, but the most interesting variables for you are the
  716. ones that exist for the sake of customization.  Emacs does not
  717. (usually) change the values of these variables; instead, you set the
  718. values, and thereby alter and control the behavior of certain Emacs
  719. commands.  These variables are called "options".  Most options are
  720. documented in this manual, and appear in the Variable Index (*note
  721. Variable Index::.).
  722.  
  723.    One example of a variable which is an option is `fill-column', which
  724. specifies the position of the right margin (as a number of characters
  725. from the left margin) to be used by the fill commands (*note
  726. Filling::.).
  727.  
  728. * Menu:
  729.  
  730. * Examining::           Examining or setting one variable's value.
  731. * Edit Options::        Examining or editing list of all variables' values.
  732. * Locals::              Per-buffer values of variables.
  733. * File Variables::      How files can specify variable values.
  734.  
  735. 
  736. File: emacs,  Node: Examining,  Next: Edit Options,  Prev: Variables,  Up: Variables
  737.  
  738. Examining and Setting Variables
  739. -------------------------------
  740.  
  741. `C-h v'
  742. `M-x describe-variable'
  743.      Print the value and documentation of a variable.
  744.  
  745. `M-x set-variable'
  746.      Change the value of a variable.
  747.  
  748.    To examine the value of a single variable, use `C-h v'
  749. (`describe-variable'), which reads a variable name using the
  750. minibuffer, with completion.  It prints both the value and the
  751. documentation of the variable.
  752.  
  753.      C-h v fill-column RET
  754.  
  755. prints something like
  756.  
  757.      fill-column's value is 75
  758.      
  759.      Documentation:
  760.      *Column beyond which automatic line-wrapping should happen.
  761.      Automatically becomes local when set in any fashion.
  762.  
  763. The star at the beginning of the documentation indicates that this
  764. variable is an option.  `C-h v' is not restricted to options; it
  765. allows any variable name.
  766.  
  767.    If you know which option you want to set, you can use `M-x
  768. set-variable' to set it.  This prompts for the variable name in the
  769. minibuffer (with completion), and then prompts for a Lisp expression
  770. for the new value using the minibuffer a second time.  For example,
  771.  
  772.      M-x set-variable RET fill-column RET 75 RET
  773.  
  774. sets `fill-column' to 75, like executing the Lisp expression
  775.  
  776.      (setq fill-column 75)
  777.  
  778.    Setting variables in this way, like all means of customizing Emacs
  779. except where explicitly stated, affects only the current Emacs session.
  780.  
  781. 
  782. File: emacs,  Node: Edit Options,  Next: Locals,  Prev: Examining,  Up: Variables
  783.  
  784. Editing Variable Values
  785. -----------------------
  786.  
  787. `M-x list-options'
  788.      Display a buffer listing names, values and documentation of all
  789.      options.
  790.  
  791. `M-x edit-options'
  792.      Change option values by editing a list of options.
  793.  
  794.    `M-x list-options' displays a list of all Emacs option variables, in
  795. an Emacs buffer named `*List Options*'.  Each option is shown with its
  796. documentation and its current value.  Here is what a portion of it
  797. might look like:
  798.  
  799.      ;; exec-path:
  800.      ("." "/usr/local/bin" "/usr/ucb" "/bin" "/usr/bin" "/u2/emacs/etc")
  801.      *List of directories to search programs to run in subprocesses.
  802.      Each element is a string (directory name)
  803.      or nil (try the default directory).
  804.      ;;
  805.      ;; fill-column:
  806.      75
  807.      *Column beyond which automatic line-wrapping should happen.
  808.      Automatically becomes local when set in any fashion.
  809.      ;;
  810.  
  811.    `M-x edit-options' goes one step further and immediately selects the
  812. `*List Options*' buffer; this buffer uses the major mode Options mode,
  813. which provides commands that allow you to point at an option and
  814. change its value:
  815.  
  816. `s'
  817.      Set the variable point is in or near to a new value read using the
  818.      minibuffer.
  819.  
  820. `x'
  821.      Toggle the variable point is in or near: if the value was `nil',
  822.      it becomes `t'; otherwise it becomes `nil'.
  823.  
  824. `1'
  825.      Set the variable point is in or near to `t'.
  826.  
  827. `0'
  828.      Set the variable point is in or near to `nil'.
  829.  
  830. `n'
  831. `p'
  832.      Move to the next or previous variable.
  833.  
  834. 
  835. File: emacs,  Node: Locals,  Next: File Variables,  Prev: Edit Options,  Up: Variables
  836.  
  837. Local Variables
  838. ---------------
  839.  
  840. `M-x make-local-variable'
  841.      Make a variable have a local value in the current buffer.
  842.  
  843. `M-x kill-local-variable'
  844.      Make a variable use its global value in the current buffer.
  845.  
  846. `M-x make-variable-buffer-local'
  847.      Mark a variable so that setting it will make it local to the
  848.      buffer that is current at that time.
  849.  
  850.    You can make any variable "local" to a specific Emacs buffer.  This
  851. means that the variable's value in that buffer is independent of its
  852. value in other buffers.  A few variables are always local in every
  853. buffer.  All other Emacs variables have a "global" value which is in
  854. effect in all buffers that have not made the variable local.
  855.  
  856.    Major modes always make the variables they set local to the buffer. 
  857. This is why changing major modes in one buffer has no effect on other
  858. buffers.
  859.  
  860.    `M-x make-local-variable' reads the name of a variable and makes it
  861. local to the current buffer.  Further changes in this buffer will not
  862. affect others, and changes in the global value will not affect this
  863. buffer.
  864.  
  865.    `M-x make-variable-buffer-local' reads the name of a variable and
  866. changes the future behavior of the variable so that it automatically
  867. becomes local when it is set.  More precisely, once you have marked a
  868. variable in this way, the usual ways of setting the variable will
  869. automatically invoke `make-local-variable' first.  We call such
  870. variables "per-buffer" variables.
  871.  
  872.    Some important variables have been marked per-buffer already.  They
  873. include `abbrev-mode', `auto-fill-function', `case-fold-search',
  874. `comment-column', `ctl-arrow', `fill-column', `fill-prefix',
  875. `indent-tabs-mode', `left-margin', 
  876. `mode-line-format', `overwrite-mode', `selective-display-ellipses', 
  877. `selective-display', `tab-width', and `truncate-lines'.  Some other
  878. variables are always local in every buffer, but they are used for
  879. internal purposes.
  880.  
  881.    Note: the variable `auto-fill-function' was formerly named
  882. `auto-fill-hook'.
  883.  
  884.    If you want that a variable ceases to be local to the current
  885. buffer, call `M-x kill-local-variable' and provide the name of a
  886. variable to the prompt.  The global value of the variable is again in
  887. effect in this buffer.  Setting the major mode kills all the local
  888. variables of the buffer.
  889.  
  890.    To set the global value of a variable, regardless of whether the
  891. variable has a local value in the current buffer, you can use the Lisp
  892. function `setq-default'.  It works like `setq'.  If there is a local
  893. value in the current buffer, the local value is not affected by
  894. `setq-default'; thus, the new global value may not be visible until
  895. you switch to another buffer.  For example,
  896.  
  897.      (setq-default fill-column 75)
  898.  
  899. `setq-default' is the only way to set the global value of a variable
  900. that has been marked with `make-variable-buffer-local'.
  901.  
  902.    Programs can look at a variable's default value with
  903. `default-value'.  This function takes a symbol as an argument and
  904. returns its default value.  The argument is evaluated; usually you
  905. must quote it explicitly.  For example,
  906.  
  907.      (default-value 'fill-column)
  908.  
  909. 
  910. File: emacs,  Node: File Variables,  Prev: Locals,  Up: Variables
  911.  
  912. Local Variables in Files
  913. ------------------------
  914.  
  915.    A file can contain a "local variables list", which specifies the
  916. values to use for certain Emacs variables when that file is edited. 
  917. Visiting the file checks for a local variables list and makes each
  918. variable in the list local to the buffer in which the file is visited,
  919. with the value specified in the file.
  920.  
  921.    A local variables list goes near the end of the file, in the last
  922. page.  (It is often best to put it on a page by itself.)  The local
  923. variables list starts with a line containing the string `Local
  924. Variables:', and ends with a line containing the string `End:'.  In
  925. between come the variable names and values, one set per line, as
  926. `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
  927. literally.
  928.  
  929.    The line which starts the local variables list does not have to say
  930. just `Local Variables:'.  If there is other text before `Local
  931. Variables:', that text is called the "prefix", and if there is other
  932. text after, that is called the "suffix".  If a prefix or suffix are
  933. present, each entry in the local variables list should have the prefix
  934. before it and the suffix after it.  This includes the `End:' line. 
  935. The prefix and suffix are included to disguise the local variables list
  936. as a comment so the compiler or text formatter  will ignore it.  If
  937. you do not need to disguise the local variables list as a comment in
  938. this way, there is no need to include a prefix or a suffix.
  939.  
  940.    Two "variable" names are special in a local variables list: a value
  941. for the variable `mode' sets the major mode, and a value for the
  942. variable `eval' is simply evaluated as an expression and the value is
  943. ignored.  These are not real variables; setting them in any other
  944. context does not have the same effect.  If `mode' is used in a local
  945. variables list, it should be the first entry in the list.
  946.  
  947.    Here is an example of a local variables list:
  948.  
  949.      ;;; Local Variables: ***
  950.      ;;; mode:lisp ***
  951.      ;;; comment-column:0 ***
  952.      ;;; comment-start: ";;; "  ***
  953.      ;;; comment-end:"***" ***
  954.      ;;; End: ***
  955.  
  956.    Note that the prefix is `;;; ' and the suffix is ` ***'.  Note also
  957. that comments in the file begin with and end with the same strings. 
  958. Presumably the file contains code in a language which is enough like
  959. Lisp for Lisp mode to be useful but in which comments start and end
  960. differently.  The prefix and suffix are used in the local variables
  961. list to make the list appear as several lines of comments when the
  962. compiler or interpreter for that language reads the file.
  963.  
  964.    The start of the local variables list must be no more than 3000
  965. characters from the end of the file, and must be in the last page if
  966. the file is divided into pages.  Otherwise, Emacs will not notice it is
  967. there.  The purpose is twofold: A stray `Local Variables:' not in the
  968. last page does not confuse Emacs, and Emacs never needs to search a
  969. long file that contains no page markers and has no local variables
  970. list.
  971.  
  972.    You may be tempted to turn on Auto Fill mode with a local variable
  973. list.  That is inappropriate.  Whether you use Auto Fill mode or not is
  974. a matter of personal taste, not a matter of the contents of particular
  975. files.  If you want to use Auto Fill, set up major mode hooks with your
  976. `.emacs' file to turn it on (when appropriate) for you alone (*note
  977. Init File::.).  Don't try to use a local variable list that would
  978. impose your taste on everyone working with the file.
  979.  
  980.    Lucid GNU Emacs allows you to specify local variables in the first
  981. line of a file, in addition to specifying them in the `Local variables'
  982. section at the end of a file.
  983.  
  984.    If the first line of a file contains two occurences of ``-*-'',
  985. Emacs uses the information between them to determine what the major
  986. mode and variable settings should be.  For example, these are all
  987. legal:
  988.  
  989.          ;;; -*- mode: emacs-lisp -*-
  990.          ;;; -*- mode: postscript; version-control: never -*-
  991.          ;;; -*- tags-file-name: "/foo/bar/TAGS" -*-
  992.  
  993.    For historical reasons, the syntax ``-*- modename -*-'' is allowed
  994. as well, for example, you can use:
  995.  
  996.          ;;; -*- emacs-lisp -*-
  997.  
  998.    The variable `enable-local-variables' controls the use of local
  999. variables lists in files you visit.  The value can be `t', `nil' or
  1000. something else.  A value of `t' means local variables lists are
  1001. obeyed; `nil' means they are ignored; anything else means query.
  1002.  
  1003.    The command `M-x normal-mode' always obeys local variables lists
  1004. and ignores this variable.
  1005.  
  1006. 
  1007. File: emacs,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
  1008.  
  1009. Keyboard Macros
  1010. ===============
  1011.  
  1012.    A "keyboard macro" is a command defined by the user to abbreviate a
  1013. sequence of keys.  For example, if you discover that you are about to
  1014. type `C-n C-d' forty times, you can speed your work by defining a
  1015. keyboard macro to invoke `C-n C-d' and calling it with a repeat count
  1016. of forty.
  1017.  
  1018. `C-x ('
  1019.      Start defining a keyboard macro (`start-kbd-macro').
  1020.  
  1021. `C-x )'
  1022.      End the definition of a keyboard macro (`end-kbd-macro').
  1023.  
  1024. `C-x e'
  1025.      Execute the most recent keyboard macro (`call-last-kbd-macro').
  1026.  
  1027. `C-u C-x ('
  1028.      Re-execute last keyboard macro, then add more keys to its
  1029.      definition.
  1030.  
  1031. `C-x q'
  1032.      When this point is reached during macro execution, ask for
  1033.      confirmation (`kbd-macro-query').
  1034.  
  1035. `M-x name-last-kbd-macro'
  1036.      Give a command name (for the duration of the session) to the most
  1037.      recently defined keyboard macro.
  1038.  
  1039. `M-x insert-kbd-macro'
  1040.      Insert in the buffer a keyboard macro's definition, as Lisp code.
  1041.  
  1042.    Keyboard macros differ from other Emacs commands in that they are
  1043. written in the Emacs command language rather than in Lisp.  This makes
  1044. it easier for the novice to write them, and makes them more convenient
  1045. as temporary hacks.  However, the Emacs command language is not
  1046. powerful enough as a programming language to be useful for writing
  1047. anything general or complex.  For such things, Lisp must be used.
  1048.  
  1049.    You define a keyboard macro by executing the commands which are its
  1050. definition.  Put differently, as you are defining a keyboard macro, the
  1051. definition is being executed for the first time.  This way, you see
  1052. what the effects of your commands are, and don't have to figure them
  1053. out in your head.  When you are finished, the keyboard macro is
  1054. defined and also has been executed once.  You can then execute the same
  1055. set of commands again by invoking the macro.
  1056.  
  1057. * Menu:
  1058.  
  1059. * Basic Kbd Macro::     Defining and running keyboard macros.
  1060. * Save Kbd Macro::      Giving keyboard macros names; saving them in files.
  1061. * Kbd Macro Query::     Keyboard macros that do different things each use.
  1062.  
  1063. 
  1064. File: emacs,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Prev: Keyboard Macros,  Up: Keyboard Macros
  1065.  
  1066. Basic Use
  1067. ---------
  1068.  
  1069.    To start defining a keyboard macro, type `C-x ('
  1070. (`start-kbd-macro').  From then on, anything you type continues to be
  1071. executed, but also becomes part of the definition of the macro.  `Def'
  1072. appears in the mode line to remind you of what is going on.  When you
  1073. are finished, the `C-x )' command (`end-kbd-macro') terminates the
  1074. definition, without becoming part of it.
  1075.  
  1076.    For example
  1077.  
  1078.      C-x ( M-f foo C-x )
  1079.  
  1080. defines a macro to move forward a word and then insert `foo'.
  1081.  
  1082.    You can give `C-x )' a repeat count as an argument, in which case it
  1083. repeats the macro that many times right after defining it, but defining
  1084. the macro counts as the first repetition (since it is executed as you
  1085. define it).  If you give `C-x )' an argument of 4, it executes the
  1086. macro immediately 3 additional times.  An argument of zero to `C-x e'
  1087. or `C-x )' means repeat the macro indefinitely (until it gets an error
  1088. or you type `C-g').
  1089.  
  1090.    Once you have defined a macro, you can invoke it again with the
  1091. `C-x e' command (`call-last-kbd-macro').  You can give the command a
  1092. repeat count numeric argument to execute the macro many times.
  1093.  
  1094.    To repeat an operation at regularly spaced places in the text,
  1095. define a macro and include as part of the macro the commands to move
  1096. to the next place you want to use it.  For example, if you want to
  1097. change each line, you should position point at the start of a line,
  1098. and define a macro to change that line and leave point at the start of
  1099. the next line.  Repeating the macro will then operate on successive
  1100. lines.
  1101.  
  1102.    After you have terminated the definition of a keyboard macro, you
  1103. can add to the end of its definition by typing `C-u C-x ('.  This is
  1104. equivalent to plain `C-x (' followed by retyping the whole definition
  1105. so far.  As a consequence it re-executes the macro as previously
  1106. defined.
  1107.  
  1108. 
  1109. File: emacs,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
  1110.  
  1111. Naming and Saving Keyboard Macros
  1112. ---------------------------------
  1113.  
  1114.    To save a keyboard macro for longer than until you define the next
  1115. one, you must give it a name using `M-x name-last-kbd-macro'.  This
  1116. reads a name as an argument using the minibuffer and defines that name
  1117. to execute the macro.  The macro name is a Lisp symbol, and defining
  1118. it in this way makes it a valid command name for calling with `M-x' or
  1119. for binding a key to with `global-set-key' (*note Keymaps::.).  If you
  1120. specify a name that has a prior definition other than another keyboard
  1121. macro, Emacs prints an error message and nothing is changed.
  1122.  
  1123.    Once a macro has a command name, you can save its definition in a
  1124. file.  You can then use it in another editing session.  First visit
  1125. the file you want to save the definition in.  Then use the command
  1126.  
  1127.      M-x insert-kbd-macro RET MACRONAME RET
  1128.  
  1129. This inserts some Lisp code that, when executed later, will define the
  1130. same macro with the same definition it has now.  You need not
  1131. understand Lisp code to do this, because `insert-kbd-macro' writes the
  1132. Lisp code for you.  Then save the file.  You can load the file with
  1133. `load-file' (*note Lisp Libraries::.).  If the file you save in is
  1134. your initialization file `~/.emacs' (*note Init File::.) then the
  1135. macro will be defined each time you run Emacs.
  1136.  
  1137.    If you give `insert-kbd-macro' a prefix argument, it creates
  1138. additional Lisp code to record the keys (if any) that you have bound
  1139. to the keyboard macro, so that the macro is reassigned the same keys
  1140. when you load the file.
  1141.  
  1142. 
  1143. File: emacs,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
  1144.  
  1145. Executing Macros with Variations
  1146. --------------------------------
  1147.  
  1148.    You can use `C-x q' (`kbd-macro-query'), to get an effect similar
  1149. to that of `query-replace'.  The macro asks you  each time whether to
  1150. make a change.  When you are defining the macro, type `C-x q' at the
  1151. point where you want the query to occur.  During macro definition, the
  1152. `C-x q' does nothing, but when you invoke the macro, `C-x q' reads a
  1153. character from the terminal to decide whether to continue.
  1154.  
  1155.    The special answers to a `C-x q' query are SPC, DEL, `C-d', `C-l'
  1156. and `C-r'.  Any other character terminates execution of the keyboard
  1157. macro and is then read as a command.  SPC means to continue.  DEL
  1158. means to skip the remainder of this repetition of the macro, starting
  1159. again from the beginning in the next repetition.  `C-d' means to skip
  1160. the remainder of this repetition and cancel further repetition.  `C-l'
  1161. redraws the screen and asks you again for a character to specify what
  1162. to do.  `C-r' enters a recursive editing level, in which you can
  1163. perform editing which is not part of the macro.  When you exit the
  1164. recursive edit using `C-M-c', you are asked again how to continue with
  1165. the keyboard macro.  If you type a SPC at this time, the rest of the
  1166. macro definition is executed.  It is up to you to leave point and the
  1167. text in a state such that the rest of the macro will do what you want.
  1168.  
  1169.    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
  1170. different function.  It enters a recursive edit reading input from the
  1171. keyboard, both when you type it during the definition of the macro, and
  1172. when it is executed from the macro.  During definition, the editing
  1173. you do inside the recursive edit does not become part of the macro. 
  1174. During macro execution, the recursive edit gives you a chance to do
  1175. some particularized editing.  *Note Recursive Edit::.
  1176.  
  1177.